#include "rsa.h"


void myPrint(const std::string &s, const char *name) 
{
	printf("\n\n\n\n%s: %lu bytes\n", name, s.size());
	for(unsigned int i = 0; i < s.size(); i ++)
	{
		unsigned char hex = (unsigned char)s[i];
		if(hex < 0x10)
		{
			printf("0%x", hex);
		}
		else 
		{
			printf("%x", hex);
		}
	}
	printf("\n");
}


int main()
{
	//Rsa* rsa = new Rsa("/root/key/rsa_public_key.pem", "/root/key/rsa_private_key.pem");
	Rsa* rsa = new Rsa("/root/key/makeup/public.pem", "/root/key/makeup/private.pem");

	const std::string org = "zsr20181220";
	std::string a,b,c,d;
	bool A,B,C,D;

	A = rsa->encrypt(org, a, true);
	B = rsa->decrypt(a, b, false);
	C = rsa->encrypt(b, c, false);
	D = rsa->decrypt(c, d, true);

	std::cout << A << B << C << D << std::endl;
	/*std::cout << org << std::endl;
	std::cout << a << std::endl;
	std::cout << b << std::endl;
	std::cout << c << std::endl;
	std::cout << d << std::endl;*/ 
	myPrint(org, "org");
	myPrint(a, "a");
	myPrint(b, "b");
	myPrint(c, "c");
	myPrint(d, "d");
	return 0;
}



